// File:       piscmd11.c++
// Version:    1.00
// Author:     (c) Miles Sabin, 1997
// Purpose:    unget command

// Change log:
//  27/03/97   v. 1.00

#include "piscmds.h"

#include "istream.h"
#include "streambuf.h"


// Implementation of UngetCommand

UngetCommand::UngetCommand(basic_istream_char& is)
  { execute_template(is, true); }

UngetCommand::~UngetCommand()
  {}

ios::iostate UngetCommand::execute(basic_istream_char& is)
  {
    basic_streambuf_char* sb = is.rdbuf();
    return ((sb == 0 || sb->sungetc() == basic_istream_char::traits::eof()) ? ios::badbit : ios::goodbit);
  }


// Implementation of basic_istream_char

basic_istream_char& basic_istream_char::unget()
  {
    gcount_ = 0;
    UngetCommand cmd(*this);
    return *this;
  }

